package com.jokerpan.project.controller;

import com.jokerpan.project.annotation.AccessLimit;
import com.jokerpan.project.commons.ActionResult;
import com.jokerpan.project.commons.ListResult;
import com.jokerpan.project.commons.ResultBuilder;
import com.jokerpan.project.entity.SysLogs;
import com.jokerpan.project.service.SysLogsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("logs")
@Api("日志操作Api")
@PreAuthorize("hasPermission('','admin:list')")
public class LogsController {

    @Resource
    SysLogsService sysLogsService;

    @GetMapping("/queryList")
    @AccessLimit(seconds = 6, maxCount = 5)
    @ApiOperation("查询所有日志")
    public ListResult<Object> queryList(SysLogs sysLogs) {
        return ResultBuilder.buildListSuccess(this.sysLogsService.queryList(sysLogs));
    }

    @GetMapping("/delete")
    @ApiOperation("删除日志")
    @AccessLimit(seconds = 6, maxCount = 5)
    @PreAuthorize("hasPermission('','admin:delete')")
    public ActionResult deleteById(@RequestParam("id") Integer id){
        return this.sysLogsService.deleteById(id);
    }

}
